<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:a4j="http://richfaces.org/a4j"
                template="layout/site-template.xhtml">

    <ui:define name="menu">
        <ui:include src="view/includes/menu/richmenuform.xhtml"/>
    </ui:define>

    <ui:define name="page-title">
        <h2>#{messages.searchresults_pagetitle}</h2>
    </ui:define>

    <ui:define name="left-content">
        <a4j:repeat var="_cat"
                    value="#{categoryList.resultList}">
            <rich:panel bodyClass="#{empty _cat.children ? 'hide' : ''}">
                <f:facet name="header">
                    <s:link value="#{_cat.name}"
                            view="/products.xhtml"
                            title="#{_cat.name}"
                            propagation="none">
                        <f:param name="catId"
                                 value="#{_cat.id}"/>
                    </s:link>
                </f:facet>
                <ui:repeat var="_chcat"
                           value="#{_cat.children}">
                    <rich:panel bodyClass="hide">
                        <f:facet name="header">
                            <s:link value="#{_chcat.name}"
                                    view="/page.xhtml"
                                    title="#{_chcat.name}"
                                    propagation="none">
                                <f:param name="catId"
                                         value="#{_chcat.id}"/>
                            </s:link>
                        </f:facet>
                    </rich:panel>
                </ui:repeat>
            </rich:panel>
        </a4j:repeat>
    </ui:define>

    <ui:define name="main-content-body">
        <h:form styleClass="maincontentform">
            <h:outputFormat value="#{messages.searchresults_resultmessage}"
                            styleClass="searchresultsmessage">
                <f:param value="#{productSearch.resultList.size}"/>
            </h:outputFormat> 
            <rich:dataGrid value="#{productSearch.resultList}"
                           var="_product"
                           columns="3"
                           elements="6"
                           width="600px"
                           styleClass="resultsdatagrid">
                <rich:panel bodyClass="pbody" styleClass="productitempanel">
                    <f:facet name="header">
                        <s:link value="#{_product.name}"
                                view="/product.xhtml"
                                title="#{_product.name}"
                                propagation="none">
                            <f:param name="prodId"
                                     value="#{_product.id}"/>
                        </s:link>
                    </f:facet>
                    <rich:dataList value="#{_product.files}"
                                   var="_file"
                                   styleClass="imagelist">
                        <s:link view="/product.xhtml"
                                title="#{_product.name}"
                                propagation="none">
                            <f:param name="prodId"
                                     value="#{_product.id}"/>
                            <s:graphicImage value="#{_file.croppedByte.image}"
                                            fileName="#{_file.id}_small"
                                            alt="[image]">
                                <s:transformImageSize width="60"
                                                      maintainRatio="true"/>
                            </s:graphicImage>
                        </s:link>
                    </rich:dataList>
                    <h:outputText value="#{_product.description}"
                                  escape="false"/>
                </rich:panel>
                <f:facet name="footer">
                    <rich:datascroller>
                        <s:conversationId/>
                    </rich:datascroller>
                </f:facet>
            </rich:dataGrid>
        </h:form>
    </ui:define>
</ui:composition>
